<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Home\Blog\Categorys;
use App\Models\Home\Blog\Posts;


class IndexController extends Controller
{
    protected $categorys;
    protected $posts;

    public function __construct(Categorys $categorys,Posts $posts)
    {
        $this->categorys = $categorys;
        $this->posts = $posts;
    }
    public function index()
    {
        $article_list = $this->posts->getArticleList();
       // dd($article_list);exit;
        return view('home.index.index',['article_list'=>$article_list]);
    }

    public function article($id){
        $article_id = intval($id);
        $article_id?$article_id:die('数据错误');
        $content = $this->posts->where('id','=',intval($article_id))->first();
        return view('home.index.detail',['detail'=>$content]);
    }

}
